#!/bin/sh
#ubuntu 安装autofs 工具 
apt-get install -y autofs cifs-utils
#挂载 smb 服务 配置
#   添加子配置文件
#sed -i "s/ssd.*/ssd       -fstype=btrfs,rw :UUID=9364bb40-af2b-4b71-941f-d14d1edfc699" /etc/ssh/sshd_config
sed -i '$a \/mnt/nas  /etc/smb.txt  --timeout 600' /etc/auto.master

# 安装 cifs-utilt 文件系统工具
#apt-get install -y cifs-utils
#   配置 smb 挂载信息
echo "date       -fstype=cifs,rw,username=smb,password=1813033378 ://192.168.2.252/date" >> /etc/smb.txt
echo "smb       -fstype=cifs,rw,username=admin,password=1813033378 ://192.168.2.252/path" > /etc/smb.txt
echo "shell       -fstype=cifs,rw,username=smb,password=1813033378 ://192.168.2.253/shell" >> /etc/smb.txt
echo "date       -fstype=xfs,rw :UUID=70250b26-8ebb-466e-9cc7-e58ddbc1e37b" >> /etc/smb.txt
echo "work       -fstype=ext4,rw :UUID=748ffabf-af54-4ded-8546-c7239266dce6" >> /etc/smb.txt
webdav -fstype=davfs,username=admin,password=1813033378 :http://192.168.2.252:5244/dav


echo "dav -fstype=davfs,username=admin,password=1813033378 :http://192.168.2.252:5244/dav" >> /etc/smb.txt
systemctl restart  autofs

mount -t davfs http://192.168.2.252:5244/dav/ali/1014 webdav

sed -i 's/# use_locks       1/use_locks       0/g' /etc/davfs2/davfs2.conf



apt-get install -y davfs2

sed -i 's/# dav_group       davfs2 /dav_group       root/g' /etc/davfs2/davfs2.conf

sed -i 's/# dav_user /dav_user       root/g' /etc/davfs2/davfs2.conf
sed -i 's/# dav_user /dav_user       root/g' /etc/davfs2/davfs2.conf


sed -i 's/# use_locks       1/use_locks       0/g' /etc/davfs2/davfs2.conf


apt-get install -y open-iscsi targetcli-fb tgt

cat > /etc/smb.txt << EOF
smb        -fstype=cifs,rw,username=smb,password=1813033378 ://192.168.2.252/ssd-disk
work       -fstype=btrfs,rw :UUID=af514f8d-ba55-4391-9846-3fe19e77599a
EOF





echo "sftp   -fstype=sftp,rw,username=root,password=1813033378,host=192.168.2.2   root@192.168.2.2:/root" > /etc/smb.txt

user   -fstype=sftp,user=root,password=yourpassword,host=sftp.server.com   user@sftp.server.com:/root

sftp -fstype=fuse.sftp,_netdev,url=sftp://user@example.com:/path/to/remote /root
rclone mount sftp:/mnt o: --cache-dir %SystemRoot%\TEMP --allow-other --vfs-cache-mode writes --vfs-cache-max-age 60s  --allow-non-empty

#   服务开机启动
systemctl enable autofs

#   服务重启 UUID=0c75a57b-9cd8-4453-9323-72c495102d26 /dev/disk/by-id/dm-uuid-LVM-Clk8dMBZ62YgKBbwEsHqoUHo1SaMsyLi0F8ocDJUPpVfMcflVXQJiZVJy25edxW7
systemctl restart  autofs

systemctl restart davfs2

#  if=/dev/sda of=/tmp/bark/ubuntu-20-04-4.img
#  mount -t cifs //192.168.2.250/smb /root/smb -o username=admin,password=1813033378

mount -t cifs //192.168.2.252/path /root/nas -o username=admin,password=1813033378